﻿@using DCMS.Web.Extensions;
@using DCMS.Web.Framework;
@using DCMS.Web.Framework.UI;
@using DCMS.ViewModel.Models.WareHouses;
@using DCMS.Core.Domain.Common;

@model InventoryPartTaskBillModel

<input asp-for="Id" type="hidden" />
<input asp-for="ProductId" type="hidden" />


@if (!ViewData.ModelState.IsValid)
{
    <div class="alert alert-warning alert-dismissable mt10 mb10">
        <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
        <div asp-validation-summary="All"></div>
    </div>
}

@if (Model.AuditedStatus)
{
    @await Html.PartialAsync("_Watermark")
}

<div class="panel panel-default mb10">
    <div class="panel-body p10">
        <form id="formSearch" class="form-horizontal" novalidate="novalidate">
            <div class="form-group mbn">

                <div class="col-sm-2">
                    <dcms-select asp-for="InventoryPerson" asp-items="@Model.InventoryPersons" asp-default="盘点人" asp-disabled="@(Model.InventoryStatus == (int)InventorysetStatus.Completed || Model.InventoryStatus == (int)InventorysetStatus.Canceled)" />
                </div>

                <div class="col-sm-2">
                    <dcms-select asp-for="WareHouseId" asp-items="@Model.WareHouses" asp-default="仓库" asp-disabled="@(Model.Id > 0)" />
                </div>

                <div class="col-sm-2">
                    <dcms-editor asp-for="InventoryDate" placeholder="盘点时间..." asp-disabled="@(Model.InventoryStatus == (int)InventorysetStatus.Completed || Model.InventoryStatus == (int)InventorysetStatus.Canceled?"disabled":"")" />
                </div>

                @if (Model.Id == 0)
                {
                    <div class="col-sm-4" id="StartTakeInventory_Box">
                        <button id="StartTakeInventory" type="button" class="btn btn-primary btn-block">
                            <span class="glyphicon glyphicon-play mr5" aria-hidden="true"></span> 开始盘点
                        </button>
                    </div>
                }

                @if (Model.Id > 0)
                {

                    <div class="col-sm-2" id="ResetInventory_Box">
                        <button id="ResetZeroInventory" type="button" class="btn btn-primary btn-block" @(Model.InventoryStatus == (int)InventorysetStatus.Completed || Model.InventoryStatus == (int)InventorysetStatus.Canceled ? "disabled" : "")>
                            <span class="glyphicon glyphicon-check mr5" aria-hidden="true"></span> 未填写库存的商品全部置零
                        </button>
                    </div>
                    <div class="col-sm-2" id="ResetInventory_Box">
                        <button id="ResetThisInventory" type="button" class="btn btn-primary btn-block" @(Model.InventoryStatus == (int)InventorysetStatus.Completed || Model.InventoryStatus == (int)InventorysetStatus.Canceled ? "disabled" : "")>
                            <span class="glyphicon glyphicon-check mr5" aria-hidden="true"></span> 未填写商品设置为当前库存
                        </button>
                    </div>
                }

                <div class="col-sm-2">
                    <div class="input-group">
                        <input asp-for="ProductName" class="form-control" readonly="@(Model.InventoryStatus == (int)InventorysetStatus.Completed || Model.InventoryStatus == (int)InventorysetStatus.Canceled?"readonly":"")" placeholder="查询..." />

                        <span class="input-group-btn">
                            <button id="btn_search_product" type="button" class="btn btn-default" @((Model.InventoryStatus == (int)InventorysetStatus.Completed || Model.InventoryStatus == (int)InventorysetStatus.Canceled) ? "disabled" : "")>
                                <span class="glyphicon glyphicon-search"></span>
                            </button>
                        </span>
                    </div>
                </div>
            </div>
        </form>
    </div>
</div>



@if (Model.Id != 0 && !string.IsNullOrEmpty(@Model.BillBarCode))
{
    <div class="row mtn mb10">
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">单据编号：</lable>
                <div class="col-lg-9">
                    <input asp-for="BillNumber" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">制单：</lable>
                <div class="col-lg-9">
                    <input asp-for="MakeUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3 pt20">
            <div class="form-group mbn">
                <lable class="col-lg-3 control-label">审核：</lable>
                <div class="col-lg-9">
                    <input asp-for="AuditedUserName" class="form-control-bb input-sm pbn pln prn" readonly="readonly" />
                </div>
            </div>
        </div>
        <div class="col-md-3">
            <img class="media-object mn thumbnail pull-right" src="@Model.BillBarCode" />
        </div>
    </div>
}

<div class="row mt10 mb10">
    <div class="col-md-12">
        <table id="InventoryPartTaskItems" class="table table-striped table-bordered table-hover"></table>
    </div>
</div>
